[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 cos()                   Calculate Cosine

 #include <math.h>

 double     cos(x);                      Cosine
 double     x;                           Radians

    cos() returns the cosine of 'x' radians.

    Returns:    Cosine of 'x' in the range of -1 to 1.

      Notes:    Error handling can be modified with the matherr()
                function.

   -------------------------------- Example ---------------------------------

    The following statements print the cosine of pi radians and 5.2e8 pi
    radians, and check for any loss of significance.

           #include <math.h>       /* for cos() and ERANGE */
           #include <stdio.h>      /* for printf() */
           #include <stdlib.h>     /* for errno */

           main()
           {
               double cosine, pi = 3.1415926535;

               cosine = cos(pi);
               printf("cosine of pi = %e\n", cosine);
               errno = 0;
               cosine = cos(5.2e8 * pi);
               if (errno == ERANGE)
                   printf("ERANGE error in cos()\n");
               printf("cosine of 5.2e8 * pi = %e\n", cosine);
           }


See Also: acos() cosh() matherr()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson